<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Prepares for a scan</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.yaz-scan" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">yaz_scan</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.5, PECL yaz &gt;= 0.9.0)</p><p class="refpurpose"><span class="refname">yaz_scan</span> &mdash; <span class="dc-title">Prepares for a scan</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.yaz-scan-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>yaz_scan</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$id</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$type</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$startterm</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$flags</code></span>
  ] ) : <span class="type"><span class="type void">void</span></span></div>

  <p class="para rdfs-comment">
   This function prepares for a Z39.50 Scan Request on the specified 
   connection.
  </p>
  <p class="para">
   To actually transfer the Scan Request to the server and receive the
   Scan Response, <span class="function"><a href="yaz_wait.html" class="function">yaz_wait()</a></span> must be called. Upon
   completion of <span class="function"><a href="yaz_wait.html" class="function">yaz_wait()</a></span> call
   <span class="function"><a href="yaz_error.html" class="function">yaz_error()</a></span> and <span class="function"><a href="yaz_scan_result.html" class="function">yaz_scan_result()</a></span> to
   handle the response.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.yaz-scan-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">id</code></dt>

     <dd>

      <p class="para">
       The connection resource returned by <span class="function"><a href="yaz_connect.html" class="function">yaz_connect()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">type</code></dt>

     <dd>

      <p class="para">
       Currently only type <em>rpn</em> is supported.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">startterm</code></dt>

     <dd>

      <p class="para">
       Starting term point for the scan.
      </p>
      <p class="para">
       The form in which the starting term is specified is given by parameter
       <code class="parameter">type</code>.
      </p>
      <p class="para">
       The syntax this parameter is similar to the RPN query as described in
       <span class="function"><a href="yaz_search.html" class="function">yaz_search()</a></span>. It consists of zero or more 
       <em>@attr</em>-operator specifications, then followed by 
       exactly one token.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">flags</code></dt>

     <dd>

      <p class="para">
       This optional parameter specifies additional information to control 
       the behaviour of the scan request. Three indexes are currently read 
       from the flags array:
       <em>number</em> (number of terms requested),
       <em>position</em> (preferred position of term) and
       <em>stepSize</em> (preferred step size).
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.yaz-scan-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.yaz-scan-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5689">
    <p><strong>Example #1 PHP function that scans titles</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">scan_titles</span><span style="color: #007700">(</span><span style="color: #0000BB">$id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$startterm</span><span style="color: #007700">)&nbsp;<br />{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">yaz_scan</span><span style="color: #007700">(</span><span style="color: #0000BB">$id</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"rpn"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"@attr&nbsp;1=4&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$startterm</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">yaz_wait</span><span style="color: #007700">();<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$errno&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">yaz_errno</span><span style="color: #007700">(</span><span style="color: #0000BB">$id</span><span style="color: #007700">);<br />&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$errno&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ar&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">yaz_scan_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$options</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Scan&nbsp;ok;&nbsp;'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(</span><span style="color: #0000BB">$options&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$key</span><span style="color: #DD0000">&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #DD0000">&nbsp;&amp;nbsp;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'&lt;br&nbsp;/&gt;&lt;table&gt;'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(list(</span><span style="color: #0000BB">$key</span><span style="color: #007700">,&nbsp;list(</span><span style="color: #0000BB">$k</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$term</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$tcount</span><span style="color: #007700">))&nbsp;=&nbsp;</span><span style="color: #0000BB">each</span><span style="color: #007700">(</span><span style="color: #0000BB">$ar</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(empty(</span><span style="color: #0000BB">$k</span><span style="color: #007700">))&nbsp;continue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;tr&gt;&lt;td&gt;</span><span style="color: #0000BB">$term</span><span style="color: #DD0000">&lt;/td&gt;&lt;td&gt;</span><span style="color: #0000BB">$tcount</span><span style="color: #DD0000">&lt;/td&gt;&lt;/tr&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'&lt;/table&gt;'</span><span style="color: #007700">;<br />&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Scan&nbsp;failed.&nbsp;Error:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">yaz_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

</div></div></div></body></html>